package cn.edu.tsc.controller;


import cn.edu.tsc.dao.EmpDao;
import cn.edu.tsc.pojo.Emp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/PreUpdateEmp")
public class PreUpdateEmp extends HttpServlet {

    public PreUpdateEmp() {
        super();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        int id = Integer.parseInt(req.getParameter("id"));
        EmpDao empDao = new EmpDao();
        Emp emp = empDao.selById(id);

        req.setAttribute("Emp",emp);

        req.getRequestDispatcher("updateEmp.jsp").forward(req,resp);

    }
}
